package com.log.controller;

import com.log.common.util.PageHelper;
import com.log.common.vo.ResultVo;
import com.log.pojo.LogGoods;
import com.log.service.LogGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 林永智
 * @Date: 2023/10/23/16:13
 */
@RestController
@RequestMapping("/goods")
@Api(tags = "货物管理",value = "")
public class LogGoodsController {
    @Autowired
    private LogGoodsService logGoodsService;

    @ApiOperation("添加货物")
    @PostMapping("/insertgoods")
    public ResultVo insertgoods(@RequestBody LogGoods logGoods) {
        return logGoodsService.insertLogGoods(logGoods);
    }

    @ApiOperation("删除货物")
    @GetMapping("/deletegoods")
    public ResultVo deletegoods(int id) {
        return logGoodsService.deleteLogGoodsById(id);
    }

    @ApiOperation("修改货物信息")
    @PutMapping("/updategoods")
    public ResultVo updategoods(@RequestBody LogGoods logGoods) {
        return logGoodsService.updateLogGoods(logGoods);
    }

    @ApiOperation("通过id查询货物信息")
    @GetMapping("/selectgoodsbyid")
    public ResultVo selectgoodsbyid(int id) {
        return logGoodsService.selectLogGoodsById(id);
    }

    @ApiOperation("分页查询货物信息")
    @GetMapping("/selectgoodsbypagenum")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(dataType = "int", name = "pageNum", value = "当前的页数", required = true),
                    @ApiImplicitParam(dataType = "int", name = "limit", value = "每页查询的页数", required = true)
            }
    )

    public ResultVo selectgoods(int pageNum, int limit,String current_depot_id) {
        return logGoodsService.selectLogGoodsListByPage(pageNum, limit,current_depot_id);
    }

    @ApiOperation("查询指定仓库的全部货物信息")
    @GetMapping("/selectgoodsbydepot")

    public ResultVo selectgoodsbydepot(int log_depot_id) {
        return logGoodsService.selectGoodsbyDepot(log_depot_id);
    }
}
